package com.hksj.lntm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hksj.common.core.model.Rest;
import com.hksj.lntm.dto.LiquidNitrogenAlarmDetailDTO;
import com.hksj.lntm.service.LiquidNitrogenAlarmService;
import com.hksj.lntm.vo.LiquidNitrogenAlarmDeviceInfoVO;
import com.hksj.cbm.vo.AlarmNumRankingVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author fjt
 * @data 2024/11/11 20:58
 * @describe
 */
@Api(tags = "液氮罐监测——报警列表")
@RestController
@RequestMapping("/api/lntm/alarm")
public class LiquidNitrogenAlarmController {


    @Autowired
    private LiquidNitrogenAlarmService liquidNitrogenAlarmService;


    @PostMapping("/page")
    @ApiOperation(value = "分页查询报警列表", notes = "分页查询报警列表",response = LiquidNitrogenAlarmDeviceInfoVO.class)
    public Rest<Page<LiquidNitrogenAlarmDeviceInfoVO>> pageAlarm(@RequestBody LiquidNitrogenAlarmDetailDTO dto){
        return Rest.ok(liquidNitrogenAlarmService.pageAlarm(dto));
    }


    @PostMapping("/exportList")
    @ApiOperation(value = "导出报警记录", notes = "导出报警记录")
    public void exportList(HttpServletResponse response, @RequestBody LiquidNitrogenAlarmDetailDTO query){
        liquidNitrogenAlarmService.exportAlarmList(response, query);
    }


    @PostMapping("/temperatureAlarmTotal")
    @ApiOperation(value = "温度报警次数", notes = "温度报警次数")
    public Rest<Integer> temperatureAlarmTotal(@RequestBody LiquidNitrogenAlarmDetailDTO dto){
        return Rest.ok(liquidNitrogenAlarmService.temperatureAlarmTotal(dto));
    }


    @PostMapping("/temperatureAlarmTenTop")
    @ApiOperation(value = "温度报警记录排名(前10)", notes = "温度报警记录排名(前10)",response = AlarmNumRankingVO.class)
    public Rest<List<AlarmNumRankingVO>> ranking(@RequestBody LiquidNitrogenAlarmDetailDTO dto){
        return Rest.ok(liquidNitrogenAlarmService.ranking(dto));
    }

}
